package top.ffhome.concurrent.beautiful.ch01;

import cn.hutool.log.Log;
import cn.hutool.log.LogFactory;

public class SleepInterruptTest {
    private static final Log log = LogFactory.get();

    public static void main(String[] args) throws InterruptedException {
        Thread threadOne = new Thread(() -> {
            try {
                log.info("threadOne begin sleep for 2000 seconds");
                Thread.sleep(2000000);
                log.info("threadOne awaking");
            } catch (InterruptedException e) {
                log.info("threadOne is interrupted while sleeping");
                return;
            }
            log.info("threadOne-leaving normally");
        });

        threadOne.start();
        Thread.sleep(1000);
        threadOne.interrupt();
        threadOne.join();
        log.info("main thread is over");
    }
}
